<?php


namespace app\admin\controller;


use app\admin\service\RbacService;
use app\common\controller\CommonController;
use app\common\exception\ParameterFailedException;
use app\common\exception\NotFoundException;
use app\common\model\UserModel;
use app\common\service\Lang;
use think\facade\Db;

class UserController extends CommonController
{
    public function getUserList()
    {
        $searchParams = self::getParam([]);
        $where        = [];
        foreach ($searchParams as $key => $value) {
            if (is_array($value) && $key === 'create_time') {
                $where[] = [
                    $key,
                    'between',
                    $value,
                ];
                continue;
            }
            if (strpos($value, '%') !== false) {
                $where[] = [
                    $key,
                    'like',
                    $value,
                ];
            }
            else {
                $where[] = [
                    $key,
                    '=',
                    $value,
                ];
            }
        }
        $where = [];
        $model = (new UserModel())->with(
                []
            )->order(
                [
                    //            'sea_waybill_number' => 'desc',
                    //            'case_number'        => 'desc',
                    'create_time' => 'desc',
                ]
            )->where($where)->paginate(
                [
                    'page'      => $this->page,
                    'list_rows' => $this->limit,
                ]
            );
        return retJson(Lang::GETDone, $model->toArray());
    }
}